/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.animation.time;

import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.api.Generator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.helpergenerators.EndGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.main.MainGenerator;
import pl.edu.amu.wmi.kino.visualjavafx.javafxcodegenerators.object.interfaces.Generatable;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.animationTime.KeyFrame;
import pl.edu.amu.wmi.kino.visualjavafx.model.animation.animationTime.Timeline;

/**
 *
 * @author Admin
 */
public class TimelineGenerator implements Generator,Generatable{

    @Override
    public boolean canGenerate(Object c) {
        if(c instanceof Timeline)
            return true;
        else return false;
    }

    @Override
    public void generate(StringBuilder sb, Object o,int recursionLevel,Object original) {
        this.generateStart(sb);
        this.generateUniqueAttributes(sb, o,recursionLevel);
        this.generateKeyFrames(sb, (Timeline)o, recursionLevel,original);
        this.generateEnd(sb);
    }

    @Override
    public void generateStart(StringBuilder sb){
        sb.append("T:bind Timeline{\n");
    }
    @Override
    public void generateEnd(StringBuilder sb){
        EndGenerator.generateEnd(sb);
    }
    public void generateKeyFrames(StringBuilder sb,Timeline t,int recursionLevel,Object original){
        sb.append("keyFrames:[\n");
        for(KeyFrame k : t.getKeyFramesArray()){
            MainGenerator.generateNext(k,recursionLevel,original);
            sb.append(",\n");
        }
        sb.append("]\n");
    }

    @Override
    public void generateUniqueAttributes(StringBuilder sb, Object o,int recursionLevel) {

    }

}
